'use strict';
import React, {
    Component
} from 'react'
import {
    Link
} from 'react-router'

import Header from './Common/Header'
import {
    urlKey,
    HttpService,
    Tips,
    getClassList,
    funcCheck
} from '../Tools'
import News from './News'

import notice from '../Img/icon/xlgg.png'
import taskPublish from '../Img/icon/taskPublish_index.png'
import task from '../Img/icon/task_index.png'
import classAlbum from '../Img/icon/classAlbum_index.png'
import phoneDirectories from '../Img/icon/phoneDirectories_index.png'
import subjectTimetable from '../Img/icon/subjectTimetable_index.png'
import leaveList from '../Img/icon/leaveList_index.png'
import score from '../Img/icon/score_index.png'
import growthRecord from '../Img/icon/growthRecord_index.png'
import imgMore from '../Img/icon/morefn.png'

export default class Index extends Component {
    constructor(props) {
        super(props);
        this.state = {
            teacher: false
        }
    }
    componentWillMount() {
        if (sessionStorage.funcCheck == 1)
            funcCheck()
        if (sessionStorage.appType && sessionStorage.appType != 1)
            this.setState({
                teacher: true
            })
    }

    render() {
        const {
            teacher
        } = this.state
        return (
            <div className="index_page" style={{background:teacher?'#eee':''}}>
                <Header title={teacher?'随寻通教师端':'家校通'} />
                {teacher?<News quote='true' length='1' />:''}
            <ul className='indexlist clearfix' id={teacher?'newsbox':''} >
                    <li className='index'>
                        <Link to='/Notice'>
                            <img src={notice}/>
                            <span>校内公告</span>
                        </Link>
                    </li>
                    {teacher
                        ?
                         <li className='index'>
                            <Link to='/TaskPublish'>
                                <img src={taskPublish}/>
                                <span>布置作业</span>
                            </Link>
                        </li>:''
                    }
                    <li className='index'>
                        <Link to='/Task'>
                            <img src={task}/>
                            <span>家庭作业</span>
                        </Link>
                    </li>
                    <li className='index'>
                        <Link to='/ClassAlbum'>
                            <img src={classAlbum}/>
                            <span>班级相册</span>
                        </Link>
                    </li>
                    <li className='index'>
                        <Link to='/PhoneDirectories'>
                            <img src={phoneDirectories}/>
                            <span>通讯录</span>
                        </Link>
                    </li>
                    <li className='index'>
                        <Link to='/SubjectTimetable'>
                            <img src={subjectTimetable}/>
                            <span>班级课表</span>
                        </Link>
                    </li>
                    <li className='index'>
                        <Link to='/LeaveList'>
                            <img src={leaveList}/>
                            <span>请假信息</span>
                        </Link>
                    </li>
                    {teacher
                        ? ''
                        :<li className='index'>
                            <Link to='/Score'>
                                <img src={score}/>
                                <span>成绩管理</span>
                            </Link>
                            </li>
                        }
                    {teacher?
                    <li className='index'>
                        <Link to='/more'>
                            <img src={imgMore}/>
                            <span>更多</span>
                        </Link>
                    </li>
                    :
                    <li className='index'>
                        <Link to='/GrowthRecord'>
                            <img src={growthRecord}/>
                            <span>成长记录</span>
                        </Link>
                    </li>
                    }
                </ul>
            </div>
        )
    }
}
